home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-25 | 16.4 KB | 498 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWPart.h
- // Release Version: $ ODF 1 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWPART_H
- #define FWPART_H
-
- #ifndef FWEVENTH_H
- #include "FWEventH.h"
- #endif
-
- #ifndef FWPRTDEF_H
- #include "FWPrtDef.h"
- #endif
-
- #ifndef FWWINDOW_H
- #include "FWWindow.h"
- #endif
-
- // ----- Foundation Includes -----
-
- #ifndef FWPSTR_H
- #include "FWPStr.h"
- #endif
-
- #ifndef FWTCOLL_H
- #include "FWTColl.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_ODPart_xh
- #include <Part.xh>
- #endif
-
- //========================================================================================
- // Forward Declarations
- //========================================================================================
-
- class ODFrame;
- class ODWindow;
- class ODSession;
- class ODDraft;
-
- class FW_CFrame;
- class FW_CSelection;
- class FW_CPoint;
- class FW_CMenuBar;
- class FW_CEventDispatcher;
- class FW_CCommand;
- class FW_CPrivOrderedCollection;
- class FW_CCloneInfo;
- class FW_CPullDownMenu;
- class FW_CWindow;
- class FW_CPresentation;
- class FW_CExtensionManager;
- class FW_CLinkManager;
- class FW_CIdler;
- class FW_CSemanticInterface;
-
- class FW_CPrintInfo;
- class FW_CPresentationCollection;
- class FW_CContent;
- class FW_CDataInterchange;
-
- //========================================================================================
- // class FW_CPart
- //========================================================================================
-
- class FW_CPart : public FW_MEventHandler
- {
- friend class ODFModule_FW_SOMPart;
- friend class FW_CPartPresentationIterator;
- friend class FW_CPartFrameIterator;
- friend class FW_CPartLinkSourceIterator;
- friend class FW_CPartLinkDestIterator;
- friend class FW_CIdler;
-
- public:
- FW_DECLARE_CLASS
- FW_DECLARE_AUTO(FW_CPart)
-
- //----------------------------------------------------------------------------------------
- // Initialization/Destruction
- //
- public:
- FW_CPart(ODPart* odPart,
- FW_Instance partInstance,
- FW_ResourceId partInfoID);
-
- virtual void Initialize(Environment *ev);
- virtual ~FW_CPart();
-
- //----------------------------------------------------------------------------------------
- // Inherited from FW_MEventHander
- //
- public:
- virtual FW_Boolean HandleAdjustMenus(Environment *ev,
- FW_CMenuBar* menuBar,
- FW_Boolean hasMenuFocus,
- FW_Boolean isRoot);
-
- //----------------------------------------------------------------------------------------
- // New API
- //
- public:
- //--------------------------------------------------------------------------
- // method from ODPart
- ODStorageUnit* GetStorageUnit(Environment *ev) const;
-
- virtual void Release(Environment *ev);
- virtual void ReleaseAll(Environment *ev);
-
- FW_Boolean GetPartName(Environment *ev, FW_CString& partName) const;
- // Returns true if the part has a name. Returns false otherwise and partName is
- // then set to the name in the partInfo resource
-
- virtual ODSize Purge(Environment *ev, ODSize size);
-
- //--------------------------------------------------------------------------
- // Draft
-
- virtual FW_Boolean IsReadOnly(Environment* ev) const;
- ODDraft* GetDraft(Environment* ev) const;
-
- //--------------------------------------------------------------------------
- // Presentation
-
- FW_CPresentation* RegisterPresentation(Environment *ev,
- ODType presentationType,
- FW_Boolean defaultPresentation,
- FW_CSelection* selection = NULL);
- virtual FW_CPresentation* ValidatePresentation(Environment *ev,
- FW_CPresentation* presentation,
- FW_Boolean isRootFrame) const;
- FW_CPresentation* FindPresentation(Environment *ev,
- ODTypeToken presentationType) const;
-
- //--------------------------------------------------------------------------
- // Document Window Creation
-
- virtual FW_CWindow* NewDocumentWindow(Environment* ev);
-
- //--------------------------------------------------------------------------
- // Frame
-
- virtual FW_CFrame* NewFrame(Environment *ev,
- ODFrame* odFrame,
- FW_CPresentation* presentation,
- FW_Boolean fromStorage) = 0;
-
- FW_Boolean IsValidDisplayFrame(Environment *ev,
- ODStorageUnitID displayFrameID) const;
-
- FW_Boolean HasSelectionFocus(Environment *ev) const;
-
- //--------------------------------------------------------------------------
- // Menus
-
- virtual void InstallMenus(Environment *ev, FW_CMenuBar* menuBar);
-
- //--------------------------------------------------------------------------
- // Getters/Setters
-
- ODPart* GetODPart(Environment *ev) const;
-
- FW_CFrame* GetLastActiveFrame(Environment *ev) const;
-
- ODFacet* GetActiveFacet(Environment *ev) const;
-
- FW_CMenuBar* GetMenuBar(Environment *ev) const;
-
- unsigned long CountDisplayFrame(Environment *ev) const;
-
- ODSession* GetSession(Environment *ev) const;
-
- ODValueType GetPartKind(Environment *ev) const;
-
- FW_Instance GetPartInstance(Environment *ev) const;
- FW_ResourceId GetViewAsIconID(Environment *ev) const;
-
- FW_CEventDispatcher* GetEventDispatcher(Environment *ev) const;
-
- void SetPrintInfo(FW_CPrintInfo* printInfo);
- FW_CPrintInfo* GetPrintInfo() const;
-
- //--------------------------------------------------------------------------
- // Change
-
- void Changed(Environment *ev);
-
- //--------------------------------------------------------------------------
- // Linking
-
- virtual FW_CLinkManager* NewLinkManager(Environment* ev);
- FW_CLinkManager* GetLinkManager(Environment* ev) const;
-
- virtual void LinkStatusChanged(Environment *ev, ODFrame* odFrame);
-
- //--------------------------------------------------------------------------
- // Externalize/Internalize Content
-
- virtual FW_CContent* NewPartContent(Environment* ev) = 0;
-
- virtual void ExternalizeContent(Environment *ev,
- ODStorageUnit* storageUnit,
- FW_CCloneInfo* cloneInfo);
- // Should never have to be overriden. Use your content object instead
- virtual void InternalizeContent(Environment *ev,
- ODStorageUnit* storageUnit,
- FW_CCloneInfo* cloneInfo);
- // Should never have to be overriden. Use your content object instead
-
- virtual void AddProperties(Environment *ev, ODStorageUnit* storageUnit);
- // Override AddProperties to add other properties/values than the standard
- // kODContentProperty/partKind
- virtual void ClearPartStorage(Environment* ev, ODStorageUnit* storageUnit);
- // Override ClearPartStorage if your are supporting other value than the standard partKind or
- // your don't want the partKind value to be cleared before each externalize
- virtual FW_Boolean IsValidContentValue(Environment* ev, ODType type);
- // Override if your part support more than the standard partKind value. The default implementation
- // will remove all value not equal to partKind
-
- FW_CContent* GetContent(Environment* ev) const;
- FW_CDataInterchange* GetDataInterchange(Environment* ev) const;
-
- //--------------------------------------------------------------------------
- // Commands
-
- ODTranslateResult TranslateData(Environment* ev,
- ODStorageUnit* storageUnit,
- ODType translateKind,
- ODType desiredKind);
-
- //--------------------------------------------------------------------------
- // Extensions
-
- FW_CExtensionManager* GetExtensionManager(Environment *ev) const;
-
- //--------------------------------------------------------------------------
- // Scripting
-
- FW_CSemanticInterface* GetSemanticInterface(Environment *ev) const;
-
- //----------------------------------------------------------------------------------------
- // Internal API (you should never have to called it)
- //
- public:
- virtual void PrivSetLastActiveFrame(FW_CFrame* lastActiveFrame);
- void PrivEnableMenuBar(Environment *ev, FW_Boolean enable, FW_Boolean appleMenu);
-
- // ----- Presentation Management -----
- FW_CPresentation* PrivGetPresentation(Environment *ev, ODFrame* odFrame) const;
- void PrivAddPresentation(FW_CPresentation* presentation);
- void PrivRemovePresentation(FW_CPresentation* presentation);
-
- // ----- Cloning -----
- virtual void PrivCloneInto(Environment *ev,
- ODDraftKey key,
- ODStorageUnit* toSU,
- ODFrame* scope);
-
- // ----- Idle Management -----
- void PrivCountIdleRegistering(FW_Boolean registering);
-
- // ----- Session Globals -----
- void PrivInitGlobals(Environment *ev);
- void PrivReleaseGlobals();
-
- // ----- Presentation Factory -----
- virtual FW_CPresentation* PrivNewPresentation(Environment *ev,
- FW_CSelection* selection,
- ODTypeToken presentationType);
-
- // ----- Data Interchanged Factory -----
- virtual FW_CDataInterchange* PrivNewDataInterchange(Environment* ev);
-
- // ----- Event Dispatcher Factory -----
- virtual FW_CEventDispatcher* PrivNewEventDispatcher(Environment *ev);
-
- // ----- Content Property cleaning -----
- void PrivCleanseContentProperty(Environment* ev,
- ODStorageUnit* storageUnit);
-
- //----- Extensions
- void PrivSetExtensionManager(FW_CExtensionManager* manager);
-
- //----- Scripting
- void PrivSetSemanticInterface(FW_CSemanticInterface* semInt);
-
- //----------------------------------------------------------------------------------------
- // Data members
- //
- public:
- static unsigned short gSessionGlobalsCount;
-
- static ODTypeToken gSelectionFocusToken;
- static ODTypeToken gMenuFocusToken;
- static ODTypeToken gKeyFocusToken;
- static ODTypeToken gModalFocusToken;
- static ODTypeToken gClipboardFocusToken;
- static ODTypeToken gScrollingFocusToken;
- static ODTypeToken gViewAsFrameToken;
- static ODTypeToken gViewAsSmallIconToken;
- static ODTypeToken gViewAsLargeIconToken;
- static ODTypeToken gViewAsThumbnailToken;
-
- #ifdef FW_BUILD_MAC
- static ODType gMacPICTDataType;
- static ODType gMacPICTFileType;
-
- static ODType gMachfsDataType;
-
- static ODType gMacTEXTDataType;
- static ODType gMacTEXTFileType;
-
- static ODType gMacMooVFileType;
- #endif
-
- private:
- ODPart* fODPart;
-
- // [HLX] could be globals
- FW_ResourceId fPartInfoID; // Part Info resource ID
- FW_ResourceId fViewAsIconID; // Default View As Icon ID
- ODValueType fPartKind; // Part Kind
- FW_CString fPartUserName; // user name
-
- short fIdleCount;
- short fModalDialogCount; // number of nested modal dialogs
-
- FW_CMenuBar* fMenuBar; // This is the current menubar
- FW_CFrame* fLastActiveFrame;
- FW_TOrderedCollection<FW_CPresentation>* fPresentations;
- FW_CPresentation* fDefaultPresentation;
-
- FW_Instance fPartInstance;
- FW_CIdler* fIdler; // Idler object attached to the part (NULL if part not registered)
-
- FW_CLinkManager* fLinkManager; // NULL if Part doesn't create Links
-
- FW_CEventDispatcher* fEventDispatcher; // Event Dispatcher
-
- FW_CExtensionManager* fExtensionManager;
-
- FW_CSemanticInterface* fSemanticInterface;
-
- FW_CPrintInfo* fPrintInfo; // May be NULL
-
- FW_CContent* fContent;
- FW_CDataInterchange* fDataInterchange;
- };
-
- //========================================================================================
- // Inlines
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CPart::GetEventDispatcher
- //----------------------------------------------------------------------------------------
- inline FW_CEventDispatcher* FW_CPart::GetEventDispatcher(Environment*) const
- {
- return fEventDispatcher;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPart::GetPartInstance
- //----------------------------------------------------------------------------------------
- inline FW_Instance FW_CPart::GetPartInstance(Environment*) const
- {
- return fPartInstance;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPart::GetViewAsIconID
- //----------------------------------------------------------------------------------------
- inline FW_ResourceId FW_CPart::GetViewAsIconID(Environment*) const
- {
- return fViewAsIconID;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPart::GetStorageUnit
- //----------------------------------------------------------------------------------------
- inline ODStorageUnit* FW_CPart::GetStorageUnit(Environment *ev) const
- {
- return fODPart->GetStorageUnit(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPart::GetLastActiveFrame
- //----------------------------------------------------------------------------------------
- inline FW_CFrame* FW_CPart::GetLastActiveFrame(Environment*) const
- {
- return fLastActiveFrame;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPart::GetMenuBar
- //----------------------------------------------------------------------------------------
- inline FW_CMenuBar* FW_CPart::GetMenuBar(Environment*) const
- {
- return fMenuBar;
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CPart::GetPartKind
- //---------------------------------------------------------------------------------------
- inline ODValueType FW_CPart::GetPartKind(Environment*) const
- {
- return fPartKind;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPart::GetODPart
- //----------------------------------------------------------------------------------------
- inline ODPart* FW_CPart::GetODPart(Environment*) const
- {
- return fODPart;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPart::PrivSetExtensionManager
- //----------------------------------------------------------------------------------------
- inline void FW_CPart::PrivSetExtensionManager(FW_CExtensionManager* manager)
- {
- fExtensionManager = manager;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPart::GetExtensionManager
- //----------------------------------------------------------------------------------------
- inline FW_CExtensionManager* FW_CPart::GetExtensionManager(Environment*) const
- {
- return fExtensionManager;
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CPart::GetLinkManager
- //----------------------------------------------------------------------------------------
- inline FW_CLinkManager* FW_CPart::GetLinkManager(Environment*) const
- {
- return fLinkManager;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPart::PrivSetSemanticInterface
- //----------------------------------------------------------------------------------------
- inline void FW_CPart::PrivSetSemanticInterface(FW_CSemanticInterface* semInt)
- {
- fSemanticInterface = semInt;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPart::GetSemanticInterface
- //----------------------------------------------------------------------------------------
- inline FW_CSemanticInterface* FW_CPart::GetSemanticInterface(Environment*) const
- {
- return fSemanticInterface;
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CPart::GetContent
- //----------------------------------------------------------------------------------------
- inline FW_CContent* FW_CPart::GetContent(Environment*) const
- {
- return fContent;
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CPart::GetDataInterchange
- //----------------------------------------------------------------------------------------
- inline FW_CDataInterchange* FW_CPart::GetDataInterchange(Environment*) const
- {
- return fDataInterchange;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPart::PrivSetLastActiveFrame
- //----------------------------------------------------------------------------------------
- inline void FW_CPart::PrivSetLastActiveFrame(FW_CFrame* lastActiveFrame)
- {
- // this is the frame which takes the selection focus when the part is active
- // (it is not set to NULL when the part becomes inactive)
- fLastActiveFrame = lastActiveFrame;
- }
-
-
- #endif
-
-
-
-